package cn.com.digitalnet.ad.repository.jpa;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import cn.com.digitalnet.ad.entity.User;

/**
 * 与UserDaoCustom一起，为UserDao增加用户自定义持久层逻辑，麻烦死了
 * @author qidafang
 */
public class UserDaoImpl implements UserDaoCustom{

	/**
	 * 注入jpa上下文
	 */
	@PersistenceContext private EntityManager entityManager;

	/**
	 * 自定义持久层方法实现
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List<User> getUsersNotAdmin(){
		Query q = entityManager
				.createQuery("from User u where loginName != :loginName")
				.setParameter("loginName", "Admin");
		return ((List<User>)q.getResultList());
	}
	
}
